<?php /* SVN: $Id: admin_index.ctp 2754 2010-08-16 06:18:32Z boopathi_026ac09 $ */ ?>
<?php if(empty($this->params['named']['stat']) && !isset($this->data['Transaction']['tab_check']) && !$isAjax): ?>
		<div class="Transaction index">
<div class="container_24 space-top clearfix">
<div class="shodow-tl">
   <div class="shodow-tr">
    <div class="shodow-tm"> </div>
  </div>
</div>
<div class="shodow clearfix">
					<h2 class="project-title"><?php echo __l('Transactions'); ?></h2>
					<?php echo $this->element('user-avatar', array('config' => 'sec')); ?>
</div>
				<div class="shad-bg-lft clearfix">
					<div class="shad-bg-rgt">
						<div class="shad-bg">
							<div class="main-section">
								<div class="summary-block clearfix">
									<h3><?php echo __l('Account Summary'); ?></h3>
									<?php if(!empty($is_wallet_enabled)) :?>
									<dl class="summary-list  clearfix">
										<dt><?php echo __l('Account Balance');?></dt>
											<dd class="available-balance round-3"><?php echo Configure::read('site.currency').$this->Html->cCurrency($user_available_balance);?></dd>
										<dt><?php echo __l('Withdraw Request');?></dt>
											<dd class="widthdraw-request round-3"><?php echo Configure::read('site.currency').$this->Html->cCurrency($blocked_amount);?></dd>
									</dl>
									<?php endif; ?>
								</div>
								<?php echo $this->Form->create('Transaction', array('action' => 'index' ,'class' => 'normal js-ajax-form {"container":"js-responses","transaction":"true"}')); ?>
									<div class="transaction-category">
							
											<?php echo $this->Form->input('filter', array('default'=>__l('all'),'type' => 'radio','options'=>$filter,'legend'=>false,'class' =>'js-transaction-filter ')); ?>
								
										<div class="js-filter-window hide clearfix">
											<div class="clearfix transection-date-time-block date-time-block">
												<div class="input date-time grid_left clearfix">
													<div class="js-datetime">
														<?php echo $this->Form->input('from_date', array('label' => __l('From'), 'type' => 'date', 'orderYear' => 'asc', 'minYear' => date('Y')-10, 'maxYear' => date('Y'), 'div' => false, 'empty' => __l('Please Select'))); ?>
													</div>
												</div>
												<div class="input date-time end-date-time-block grid_left clearfix">
													<div class="js-datetime">
														<?php echo $this->Form->input('to_date', array('label' => __l('To '),  'type' => 'date', 'orderYear' => 'asc', 'minYear' => date('Y')-10, 'maxYear' => date('Y'), 'div' => false, 'empty' => __l('Please Select'))); ?>
													</div>
												</div>
												<?php
												echo $this->Form->input('tab_check', array('type' => 'hidden','value' => 'tab_check'));?>
										<div class="grid_left"><?php echo $this->Form->submit(__l('Filter'));?></div>
											</div>
											
										</div>
									</div>
								<?php echo $this->Form->end(); ?>
								<div class="clearfix counter-block js-response js-responses">
<?php endif; ?>
										<?php echo $this->element('paging_counter');?> 
										<table class="list">
											<tr>
												<th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Created'),'created');?></div> </th>
												<th class="dl"><div class="js-pagination"><?php echo __l('Message'); ?></div></th>
												<th class="dr"><div class="js-pagination credit round-3"><?php echo $this->Paginator->sort(__l('Credit'), 'amount').' ('.Configure::read('site.currency').')';?></div></th>
												<th class="dr"><div class="js-pagination debit round-3"><?php echo $this->Paginator->sort(__l('Debit'), 'amount').' ('.Configure::read('site.currency').')';?></div></th>
											</tr>
											<?php
												$total_credit=0;
												if (!empty($transactions)):
													$i = 0;
													$total_credit=0;
													$total_debit=0;
													foreach ($transactions as $transaction):
														$class = null;
														if ($i++ % 2 == 0) {
															$class = ' class="altrow"';
														}
											$to= $this->Html->cDate($duration_from);
											$from=$this->Html->cDate($duration_to);
											?>
											<tr<?php echo $class;?>>
												<td><?php echo $this->Html->cDateTimeHighlight($transaction['Transaction']['created']); ?></td>
											
												<td class="dl">
              <?php
                echo $this->Html->transactionDescription($transaction);
             ?>
			</td>
												<td class="dr">
           <?php

												if($transaction['TransactionType']['is_credit'])
												{
												$total_credit=$total_credit+$transaction['Transaction']['amount'];
													echo $this->Html->cCurrency($transaction['Transaction']['amount']);
                                                  if(($transaction['Transaction']['payment_gateway_id'] == ConstPaymentGateways::PayPal) && ($transaction['TransactionType']['id'] == ConstTransactionTypes::AmountFundedToOwner))
													{
                                                      if($transaction['ProjectFund']['Project']['project_status_id'] == ConstProjectStatus::OpenForFunding)
                                                      {
                                                         echo __l(' (Authorized)');
                                                      }
                                                      else
                                                      {
                                                         echo __l(' (Captured)');
                                                      }
                                                    }
                                                    if(($transaction['Transaction']['payment_gateway_id'] == ConstPaymentGateways::Wallet) && ($transaction['TransactionType']['id'] == ConstTransactionTypes::AmountFundedToOwner))
													{
                                                      if($transaction['ProjectFund']['Project']['project_status_id'] == ConstProjectStatus::OpenForFunding)
                                                      {
                                                         echo __l(' (Pledged)');
                                                      }
                                                      else
                                                      {
                                                         echo __l(' (Funded)');
                                                      }
                                                    }
                                                if(($transaction['Transaction']['payment_gateway_id'] == ConstPaymentGateways::PayPal) && ($transaction['TransactionType']['id'] == ConstTransactionTypes::Refunding))
													{
                                                      echo __l(' (Voided)');
                                                    }
                                                    else if(($transaction['Transaction']['payment_gateway_id'] == ConstPaymentGateways::Wallet) && ($transaction['TransactionType']['id'] == ConstTransactionTypes::Refunding))
                                                    {
                                                      echo __l(' (Refunded)');
                                                    }
                                                }
												else{
													echo '--';
												}
											 ?>
										</td>
										<td class="dr">
											<?php
												if($transaction['TransactionType']['is_credit']):
													echo '--';
												else:
													$total_debit=$total_debit+$transaction['Transaction']['amount'];
													echo $this->Html->cCurrency($transaction['Transaction']['amount']);
													if(($transaction['Transaction']['payment_gateway_id'] == ConstPaymentGateways::PayPal) && ($transaction['TransactionType']['id'] == ConstTransactionTypes::Refunded))
													{
                                                      echo __l(' (Voided)');
                                                    }
                                                    else if(($transaction['Transaction']['payment_gateway_id'] == ConstPaymentGateways::Wallet) && ($transaction['TransactionType']['id'] == ConstTransactionTypes::Refunding))
                                                    {
                                                      echo __l(' (Refunded)');
                                                    }
                                                    if(($transaction['Transaction']['payment_gateway_id'] == ConstPaymentGateways::PayPal) && ($transaction['TransactionType']['id'] == ConstTransactionTypes::ProjectFunding))
													{
                                                      if($transaction['ProjectFund']['Project']['project_status_id'] == ConstProjectStatus::OpenForFunding)
                                                      {
                                                         echo __l(' (Authorized)');
                                                      }
                                                      else
                                                      {
                                                         echo __l(' (Captured)');
                                                      }
                                                    }
                                                    if(($transaction['Transaction']['payment_gateway_id'] == ConstPaymentGateways::Wallet) && ($transaction['TransactionType']['id'] == ConstTransactionTypes::AmountFundedToOwner))
													{
                                                      if($transaction['ProjectFund']['Project']['project_status_id'] == ConstProjectStatus::OpenForFunding)
                                                      {
                                                         echo __l(' (Pledged)');
                                                      }
                                                      else
                                                      {
                                                         echo __l(' (Funded)');
                                                      }
                                                    }
												endif;
											 ?>
										</td>
											</tr>
											<?php
													endforeach; ?>
											<tr>
				<td class="dr" colspan="2"><span><?php echo __l('Total: ');?></span><span class="duration"><?php echo $from . ' ' . __l('to') . ' ' . $to; ?></span></td>
				<td class="dr credit-total"><?php echo $this->Html->cCurrency($total_credit_amount);?></td>
				<td class="dr debit-total"><?php echo $this->Html->cCurrency($total_debit_amount);?></td>
			</tr>
											<?php
												else:
											?>
											<tr>
												<td colspan="11" class="notice"><?php echo __l('No Transactions available');?></td>
											</tr>
											<?php
												endif;
											?>
										</table>
										<?php if (!empty($transactions)) : ?>
											<div class="js-pagination">
												<?php echo $this->element('paging_links'); ?>
											</div>
										<?php endif; ?>
<?php if(empty($this->params['named']['stat']) && !isset($this->data['Transaction']['tab_check']) && !$isAjax): ?>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="l-curve-bot">							
						<div class="r-curve-bot">
							<div class="bot-bg"></div>
						</div>
					</div>
				</div>
			</div>
<?php endif; ?>